package com.ziqikeji.xianyan.entity.recommend;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ziqikeji.xianyan.common.BaseEntity;
import com.ziqikeji.xianyan.entity.article.Article;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

/**
 * 文章推荐
 * @author liuyu
 */
@Entity
@Table(name = "article_recommend")
public class ArticleRecommend extends BaseEntity {

    /**
     * 推荐文章
     */
    private Article article;
    /**
     * 推荐理由
     */
    private String recommendedReason;
    /**
     * 推荐时间
     */
    private Date recommendedTime;
    /**
     * 主推页面需要展示的图片
     */
    private String indexShowImageUrl;

    @ManyToOne
    @JoinColumn(name = "article_id")
    public Article getArticle() {
        return article;
    }

    public void setArticle(Article article) {
        this.article = article;
    }

    public String getRecommendedReason() {
        return recommendedReason;
    }

    public void setRecommendedReason(String recommendedReason) {
        this.recommendedReason = recommendedReason;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @LastModifiedDate
    public Date getRecommendedTime() {
        return recommendedTime;
    }

    public void setRecommendedTime(Date recommendedTime) {
        this.recommendedTime = recommendedTime;
    }

    public String getIndexShowImageUrl() {
        return indexShowImageUrl;
    }

    public void setIndexShowImageUrl(String indexShowImageUrl) {
        this.indexShowImageUrl = indexShowImageUrl;
    }
}
